from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone

from ..models import Article


class ArticleFavorite(models.Model):
    user = models.ForeignKey(User, related_name='article_favorites')
    article = models.ForeignKey(Article)
    date = models.DateTimeField(default=timezone.now)

    class Meta:
        unique_together = ('user', 'article')
        ordering = ['-date', '-pk']
